package com.zy.explore.design.interfaces.facade.v1;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zy.explore.design.interfaces.frm.StrategyFrm;
import com.zy.explore.design.patterns.strategy.StrategyTypeEnum;
import com.zy.explore.design.patterns.strategy.StrategyUseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * description 策略模式示例Facade
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2021年05月15日 14:27
 */
@Api(tags = {"策略模式示例Facade"})
@RestController
@RequestMapping("/strategy")
public class StrategyFacade {

    @Resource
    private StrategyUseService strategyUseService;

    @ApiOperationSupport(order = 10, author = "🇨🇳中国印🇨🇳")
    @ApiOperation("根据不同类型调用不同策略")
    @PostMapping("/useStrategy")
    public Integer useStrategy(@RequestBody @Validated StrategyFrm frm) {
        strategyUseService.doSomething(frm.getStrategyTypeEnum(), frm.getParams());
        return 1;
    }

}
